<template>
    <div class="home">
        <div class="main">
            <a-card style="width: 20%;">
                <a-menu
                    id="dddddd"
                    v-model:openKeys="openKeys"
                    v-model:selectedKeys="selectedKeys"
                    style="width: 100%"
                    mode="inline"
                    :items="items"
                    @click="handleClick"
                ></a-menu>
            </a-card>
            <a-card style="width: 80%;">
                <div class="show">
                    <a-card :style="{'width': '55%', 'height': '400px', 'background-color' : '#F2F2F2', 'margin-right': '5px'}">
                        <a-carousel arrows>
                            <template #prevArrow>
                            <div class="custom-slick-arrow" style="left: 10px; z-index: 1">
                                <left-circle-outlined />
                            </div>
                            </template>
                            <template #nextArrow>
                            <div class="custom-slick-arrow" style="right: 10px">
                                <right-circle-outlined />
                            </div>
                            </template>
                            <div v-for="url in state.imgs">
                              <img :src="url" style="width: 100%; height: 350px;">
                            </div>
                        </a-carousel>
                    </a-card>
                    <a-card :style="{'width': '45%', 'height': '400px', 'background-color' : '#F2F2F2'}">
                        <a-carousel arrows>
                            <template #prevArrow>
                            <div class="custom-slick-arrow" style="left: 10px; z-index: 1">
                                <left-circle-outlined />
                            </div>
                            </template>
                            <template #nextArrow>
                            <div class="custom-slick-arrow" style="right: 10px">
                                <right-circle-outlined />
                            </div>
                            </template>
                            <div><h3>1</h3></div>
                            <div><h3>2</h3></div>
                            <div><h3>3</h3></div>
                            <div><h3>4</h3></div>
                        </a-carousel>
                    </a-card>
                </div>
            </a-card>
        </div>
    </div>
    <div class="sub1">
        <div class="sub1Line">
            <a-card title="行业报告" style="width: 40%; height: 200px;"></a-card>
            <a-card title="政策文件" style="width: 60%; height: 200px;"></a-card>
        </div>
        <div class="sub1Line">
            <a-card title="招标公告" style="width: 40%; height: 200px;"></a-card>
            <a-card title="热点研究" style="width: 60%; height: 200px;"></a-card>
        </div>
    </div>
    <div class="sub2">
        <a-card title="供应商推荐" style="width: 100%;">
          <img src="/imgs/temp.png" alt="temp" style="width: 100%;">
        </a-card>
    </div>
</template>

<script setup>
import { reactive, ref, watch, h } from 'vue'
const state = reactive({})

import { MailOutlined, AppstoreOutlined, SettingOutlined } from '@ant-design/icons-vue'
const selectedKeys = ref(['1'])
const openKeys = ref(['sub1'])
function getItem(label, key, icon, children, type) {
  return {
    key,
    icon,
    children,
    label,
    type,
  };
}
const items = reactive([
  getItem('Navigation One', 'sub1', () => h(MailOutlined), [
    getItem('Item 1', 'g1', null, [
      getItem('建筑工程', '1'), 
      getItem('装饰工程', '2'),
      getItem('安装工程', '3'),
      getItem('市政工程', '4'),
      getItem('园林绿化', '5'),
      getItem('城市轨道', '6'),
      getItem('仿古建筑', '7')], 'group')
  ])
])
console.log(items)

const handleClick = e => {
  console.log('click', e);
}
watch(openKeys, val => {
  console.log('openKeys', val);
})

import http from '@/utils/axios'

state.imgs = reactive([])
state.articles = reactive([])

const fetchBrands = async () => {
  const brands = await http.get('/home/brandPromotion/list')
  return brands
}

const fetchArticles = async () => {
  const brands = await http.get('')
  return brands
}

import { onBeforeMount } from 'vue'
onBeforeMount(async () => {
  const brands = await fetchBrands()
  // const articles = await fetchArticles()
  state.imgs = brands.data.result.records.map((item) => 'http://119.96.146.137:8090/jeecg-boot/' + item.image)
})
</script>

<style scoped>
.home{
    width: 100%;
    display: flex;
    align-items: center;
    flex-direction: column;
}
.main{
    width: 80%;
    display: flex;
    flex-direction: row;
}
.sub1{
    width: 80%;
    display: flex;
    flex-direction: column;
    margin-top: 10px;
}
.sub1Line{
    width: 100%;
    display: flex;
    flex-direction: row;
}
.sub2{
    width: 80%;
    display: flex;
    flex-direction: row;
    margin-top: 10px;
}
.show{
    display: flex;
    flex-direction: row;
    align-items: center;
}
:deep(.slick-slide) {
  text-align: center;
  height: 350px;
  line-height: 160px;
  background: #364d79;
  overflow: hidden;
}

:deep(.slick-arrow.custom-slick-arrow) {
  width: 25px;
  height: 25px;
  font-size: 25px;
  color: #fff;
  background-color: rgba(31, 45, 61, 0.11);
  transition: ease all 0.3s;
  opacity: 0.3;
  z-index: 1;
}
:deep(.slick-arrow.custom-slick-arrow:before) {
  display: none;
}
:deep(.slick-arrow.custom-slick-arrow:hover) {
  color: #fff;
  opacity: 0.5;
}

:deep(.slick-slide h3) {
  color: #fff;
}
</style>